﻿using Org.Flowertwig.Media;

namespace MediaStreamer.Containers
{
    public class MenuItem
    {
        protected string _id;
        protected string _text;
        protected string _locationId;
        protected string _navigateToLocation;
        protected string _elementId;
        protected int _sortIndex;

        public string Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public int SortIndex
        {
            get { return _sortIndex; }
            set { _sortIndex = value; GenerateId(); }
        }
        public string Text
        {
            get { return _text; }
            set { _text = value; GenerateId(); }
        }
        public string LocationId
        {
            get { return _locationId; }
            set { _locationId = value; GenerateId(); }
        }
        public string NavigateToLocation
        {
            get { return _navigateToLocation; }
            set { _navigateToLocation = value; GenerateId(); }
        }
        public string ElementId
        {
            get { return _elementId; }
            set { _elementId = value; GenerateId(); }
        }

        private void GenerateId()
        {
            if (string.IsNullOrEmpty(Text) || string.IsNullOrEmpty(LocationId) || string.IsNullOrEmpty(ElementId))
                return;

            Id = Hash.CreateId(string.Format("{0}:{1}:{2}:{3}", Text, LocationId, ElementId, NavigateToLocation));
        }
    }
}